package cn.edu.qzuie.artist.module.td.dal.mysql.workscatagory;

import java.util.*;

import cn.edu.qzuie.artist.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.edu.qzuie.artist.framework.mybatis.core.mapper.BaseMapperX;
import cn.edu.qzuie.artist.module.td.dal.dataobject.workscatagory.WorksCatagoryDO;
import org.apache.ibatis.annotations.Mapper;
import cn.edu.qzuie.artist.module.td.controller.admin.workscatagory.vo.*;

/**
 * 作品分类 Mapper
 *
 * @author 泉信管理员
 */
@Mapper
public interface WorksCatagoryMapper extends BaseMapperX<WorksCatagoryDO> {

    default List<WorksCatagoryDO> selectList(WorksCategoryListReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<WorksCatagoryDO>()
                .likeIfPresent(WorksCatagoryDO::getCategoryName, reqVO.getCategoryName())
                .eqIfPresent(WorksCatagoryDO::getParentId, reqVO.getParentId())
                .orderByDesc(WorksCatagoryDO::getId));
    }

	default WorksCatagoryDO selectByPidAndCatagoryName(Long pid, String catagoryName) {
	    return selectOne(WorksCatagoryDO::getParentId, pid, WorksCatagoryDO::getCategoryName, catagoryName);
	}

    default Long selectCountByPid(Long pid) {
        return selectCount(WorksCatagoryDO::getParentId, pid);
    }

}